package com.stx.yuanhui;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class ObjectWriter {
    public static void main(String[] args) {
        Person p = new Person("袁辉", 21, 95.5);
        String path = "E:\\2025\\双体\\作业\\4-6-parts\\work\\part_three\\1组作业\\yuanhui\\student.txt";

        try (FileOutputStream fos = new FileOutputStream(path);
             ObjectOutputStream oos = new ObjectOutputStream(fos)) {
            oos.writeObject(p);
            System.out.println("对象已序列化至文件：" + path);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
